﻿<h3>
	<span style="color: #666;">
		{if $value['stock']<=$value['group_buynum']  or $timestamp > $value['group_end_time']}
			過往團購：
		{else}
			{if $group_type == 2 }
				限量特價：
			{else}
				今日團購：
			{/if}
		{/if}
	</span>
		{$value['title']}</h3>
    	<div id="buy917_product_show">
        	<div class="adblock">
                <div class="imgbox"></div>
                <ul class="showbox"></ul>
                <div class="btnlink"></div>
            </div>
        </div><!-- buy917_product_show -->
        <div id="buy917_product_count">
        	<div id="buy917_price">
              <div class="top">
              	<h3>$ {$value['shop_price']}</h3>
              	<div class="btn">
					{if $value['stock']<=$value['group_buynum']} 
						<span class="deal-price-soldout"></span><!-- 賣完了 -->
					{elseif $timestamp > $value['group_end_time']} 
						<span class="deal-price-expire"><img src="{TPL}images/buy_end.png" /></span>   <!-- 已過期 -->
					{elseif $timestamp < $value['group_begin_time']} 
						<span class="deal-price-expire"><img src="{TPL}images/buy_not_begin.png" /></span>   <!-- 還未開始 -->
					{else} 
						{if ($_SESSION['refer']!="")}
						<span><a href="buy.php?gid={$value['gid']}&refer={$_SESSION['refer']}"><img src="{TPL}images/buy_btn.png" /></a> </span>
						{else}
						<span><a href="buy.php?gid={$value['gid']}"><img src="{TPL}images/buy_btn.png" /></a> </span>
						{/if}
					{/if}                     
                </div>
                <div class="under">
                	<table width="95%" border="0" cellpadding="2" cellspacing="0">
                          <tr>
                            <th>原　價</th>
                            <th class="discont">折　扣</th>
                            <th class="province">節　省</th>
                          </tr>
                          <tr>
                            <td align="center"><strike>${echo $value['market_price']} </strike></td>
                            <td align="center" class="discont">{php $pic=($value['shop_price']*10/$value['market_price']); echo sprintf("%1.1f",$pic)}折</td>
                            <td align="center" class="province">${php $pic1=($value['market_price']-$value['shop_price']); echo $pic1}</td>
                          </tr>
                    </table>
                 </div>
              </div>
            </div><!-- preice -->
		<br />
		
		{if $value['stock']<=$value['group_buynum']} <!-- 如果賣超過團購數量就結束-->           
            <div id="buy917_date">
                <div id="deal-timeleft" class="deal-box deal-timeleft deal-off">
                    <h3>本團購結束於</h3>
                    <div class="limitdate" style="background:none;">
                        <p class="deal-buy-ended" style="width:280px; margin-left:-40px; margin-top:6px;">20{date("y年m月d日", $value['group_end_time'])}--
						{date("H點i分", $value['group_end_time'])}</p>
                    </div>
                </div>
            </div><!--buy917_date --> 
		   
			<div id="buy917_timer"> 
                <div id="deal-status" class="deal-box deal-status deal-status-istipped">
                   <div class="deal-buy-soldout"></div><!-- 賣光了 -->
                    <p class="deal-buy-tip-total">共有 <strong>{$value['group_buynum']}</strong>人購買</p>
                 </div>
            </div><!--buy917_timer --> 
		{elseif $timestamp < $value['group_begin_time']}<!-- 團購時間 未開始-->
			 <div id="buy917_date">
                <div id="deal-timeleft" class="deal-box deal-timeleft deal-off">
                    <h3>本團購將開始於</h3>
                    <div class="limitdate" style="background:none;">
                        <p class="deal-buy-ended" style="width:280px; margin-left:-40px; margin-top:6px;">20{date("y年m月d日", $value['group_begin_time'])}--
						{date("H點i分", $value['group_begin_time'])}</p>
                    </div>
                </div>
            </div><!--buy917_date --> 
		   
			<div id="buy917_timer"> 
                <div id="deal-status" class="deal-box deal-status deal-status-istipped">
                   <div class="deal-not-begin"></div><!-- 賣光了 -->
                    <p class="deal-buy-tip-total">本檔團購未開始再等等喔^_^!! </p>
                 </div>
            </div><!--buy917_timer --> 
			
		{elseif $timestamp>$value['group_end_time']}<!-- 超過團購時間-->
				{if $value['group_usernum']>$value['group_buynum']}
					 <div id="buy917_date">
						<div id="deal-timeleft" class="deal-box deal-timeleft deal-off">
							<h3>本團購結束於</h3>
							<div class="limitdate" style="background:none;">
								<p class="deal-buy-ended"style="width:280px; margin-left:-40px; margin-top:6px;">20{date("y年m月d日", $value['group_end_time'])}--
								{date("H點i分", $value['group_end_time'])}</p>
							</div>
						</div>
					</div><!--buy917_date --> 
		   
					<div id="buy917_timer"> 
						<div id="deal-status" class="deal-box deal-status deal-status-istipped">
						   <div class="deal-buy-expired-fail"></div><!-- 團購失敗 -->
							<p class="deal-buy-tip-total">共有 <strong>{$value['group_buynum']}</strong>人購買</p>
						 </div>
					</div><!--buy917_timer --> 
				{else}
					 <div id="buy917_date">
						<div id="deal-timeleft" class="deal-box deal-timeleft deal-off">
							<h3>本團購結束於</h3>
							<div class="limitdate" style="background:none;">
                        <p class="deal-buy-ended" style="width:280px; margin-left:-40px; margin-top:6px;">20{date("y年m月d日", $value['group_end_time'])}--
						{date("H點i分", $value['group_end_time'])}</p>
							</div>
						</div>
					</div><!--buy917_date --> 
				   
					<div id="buy917_timer"> 
						<div id="deal-status" class="deal-box deal-status deal-status-istipped">
						   <div class="deal-buy-expired-succ"></div><!-- 團購成功 -->
							<p class="deal-buy-tip-total">共有 <strong>{$value['group_buynum']}</strong>人購買</p>
						 </div>
					</div><!--buy917_timer --> 
				{/if}
		{else}
           <div id="buy917_date">
           		{if $group_type == 2 }
                  <h3>剩餘數量</h3>
				{else}
                  <h3>剩餘時間</h3>
				{/if}
                  <div class="limitdate">
                  	{if $group_type == 2 }
						<ul id="counter"><li><span>{echo $value['stock']-$value['total_buynum']} &nbsp;	份</span></li></ul>
					{else}
                    <script type="text/javascript">
                        var sysSecond = parseInt('{echo $value["group_end_time"]-$timestamp}');
                        var interValObj = window.setInterval(setRemainTime, 1000); 
                        function setRemainTime()
                        {
                            if (sysSecond > 0)
                            {
                                sysSecond -= 1;
                                var second = Math.floor(sysSecond % 60);              // 計算秒     
                                var minite = Math.floor((sysSecond / 60) % 60);       //計算分
                                var hour = Math.floor((sysSecond / 3600) % 24);       //計算小時
                                var day = Math.floor((sysSecond / 3600) / 24);        //計算天
                                var timeHtml = "<li><span>"+hour+"</span><small>小時</small></li><li><span>"+minite+"</span><small>分</small></li>";
//                                if(day > 0)
//                                    timeHtml ="<li><span>"+day+"</span><small>天</small></li>" + timeHtml;
                                
                                timeHtml+="<li><span>"+second+"</span><small>秒</small></li>";
                                
                                try
                                {
                                    $("#counter").html(timeHtml);
                                }
                                catch(e){}}
                            else
                            {
                                window.clearInterval(interValObj);}
                        }
                        </script>
                    <ul id="counter"></ul>
					{/if}
					
                  </div>
            </div><!-- date -->
		{if $value['group_usernum']<=$value['group_buynum']}
           <div id="buy917_timer">
                    <div class="deal-box deal-status deal-status-open" id="deal-status">
                      <p class="deal-buy-tip-top"><strong>{$value['group_buynum']}</strong><span title="" closure_uid_ueavjb="54" se="人已購買" te="人已購買">人已購買</span></p>
                      {if $group_type != 2 }
					  	<p class="deal-buy-tip-notice">數量有限，下單要快喲！</p>
					  {/if}
                      <p class="deal-buy-on">團購已成功，<br />
                        	可繼續購買&hellip;</p>
					{if $group_type == 2 }
                      <p class="deal-buy-tip-btm">限量特價結束日期： {date("Y年m月d日 H點i分", $value['group_end_time'])}</p>
					{else}
                      <p class="deal-buy-tip-btm">{date("H點i分", $value['group_success_time'])}達到最低團購人數：<strong>{$value['group_usernum']}</strong> 人</p>
					{/if}
                </div>
               </div> 
            {else}
            <div id="buy917_timer">
                <div class="deal-box deal-status deal-status-open" id="deal-status">
                  <p class="deal-buy-tip-top"><strong>{$value['group_buynum']}</strong> 人已購買</p>
                  <p class="deal-buy-tip-notice">數量有限，先搶先贏</p>
                  <div style="width:194px; margin:0 auto; border:solid 1px #bee284; padding:0 30px; background:#f8fadf;">
                      <div style="padding-left: {echo ($value['group_buynum'])*186/$value['group_usernum']}px;" class="progress-pointer"><span></span></div>
                      <div class="progress-bar">
                        <div style="width:{echo ($value['group_buynum'])*186/$value['group_usernum']}px" class="progress-left"></div>
                        <div class="progress-right "></div>
                      </div>
                      <div class="cf">
                        <div class="min">0</div>
                        <div class="max">{$value['group_usernum']}</div>
                      </div>
                   </div>   
                  <p class="deal-buy-tip-btm">還差 <strong>{echo $value['group_usernum']-$value['group_buynum']}</strong> 人到達最低團購人數</p>
                </div>
              </div><!--timer -->
            {/if}            
            {/if}	
		   
        </div><!-- buy917_time -->